package com.itheima.users4shopping.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.goods.pojo.Address;
import com.itheima.users4shopping.mapper.AddressDao;
import com.itheima.users4shopping.service.AddressService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wang
 * @description
 * @date 2021/7/31 14:55
 */
@Service("addressService")
public class AddressServiceImpl extends ServiceImpl<AddressDao, Address> implements AddressService {
    @Override
    public List<Address> findByUserId(String username) {
        LambdaQueryWrapper<Address> wrapper = Wrappers.lambdaQuery(Address.class);
        wrapper.eq(Address::getUserId,username)
                .orderByDesc(Address::getIsDefault);
        return this.list(wrapper);
    }
}
